#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
    pid_t id = fork();
    if (id == 0)
    {
        // child
        printf("pid:%d,begin to exec!\n", getpid());
        sleep(3);
        execl("./cpptest", "./cpptest", NULL);
        // execl("/usr/bin/ls","ls","-a","-l",NULL);
        printf("pid:%d,end to exec!\n", getpid());
    }
    else
    {
        // father
        printf("wait child\n");
        pid_t rid = waitpid(-1, NULL, 0);
        if (rid > 0)
        {
            printf("wait success\n");
        }
    }
    return 0;
}

// int main()
//{
//     printf("execl begin:\n");
//     execl("/usr/bin/ls", "ls", "-a", "-l", "-n", NULL);
//     return 0;
// }
